/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

/**
 *
 * @author chapmand
 */
public enum AlarmType {
    EMAIL(0),
    GOOGLE_CALENDAR(1),
    TEXT_MESSAGE(2);
    
    private int type;

    AlarmType(final int type) {
        this.type = type;
    }

    public int getType() {
        return type;
    }

    public static AlarmType getType(final String type) {
        return getType(Integer.parseInt(type));
    }
    
    public static AlarmType getType(final int type) {
        switch (type) {
        case 0:
            return EMAIL;
        case 1:
            return GOOGLE_CALENDAR;
        case 2:
            return TEXT_MESSAGE;
        default:
            throw new EnumConstantNotPresentException(AlarmType.class, String.valueOf(type));
        }
    }
    
    public static AlarmType getTypeByName(final String str) {
        if(str.equals("EMAIL")){
            return EMAIL;
        } else if(str.equals("GOOGLE_CALENDAR")){
            return GOOGLE_CALENDAR;
        } else if(str.equals("TEXT_MESSAGE")){
            return TEXT_MESSAGE;
        } else {
            return EMAIL;
        }
    }
}
